package com.zhangzhan.gulimallmember.web;

import com.alibaba.fastjson.JSON;
import com.zhangzhan.gulimallcommcon.util.R;
import com.zhangzhan.gulimallmember.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;
import java.util.Objects;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2024/7/4 8:30
 */
@Controller
public class OrderListController {

    @Autowired
    private OrderFeignService orderFeignService;

    @RequestMapping(value = "/memberOrderList.html", method = RequestMethod.GET)
    public String orderList(@RequestParam("page") Integer page, Model model) {

        R r = orderFeignService.memberOrderItemList(Map.of("page", page));
        if (Objects.equals(r.getCode(), 0)) {

            System.out.println(JSON.toJSONString(r));

            model.addAttribute("order",r);
        }

        return "list";
    }

}
